import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BookVO, BookForm, BookQuery } from '@/api/market/book/types';

/**
 * 查询预约列表列表
 * @param query
 * @returns {*}
 */

export const listBook = (query?: BookQuery): AxiosPromise<BookVO[]> => {
  return request({
    url: '/market/book/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询预约列表详细
 * @param id
 */
export const getBook = (id: string | number): AxiosPromise<BookVO> => {
  return request({
    url: '/market/book/' + id,
    method: 'get'
  });
};

/**
 * 新增预约列表
 * @param data
 */
export const addBook = (data: BookForm) => {
  return request({
    url: '/market/book',
    method: 'post',
    data: data
  });
};

/**
 * 修改预约列表
 * @param data
 */
export const updateBook = (data: BookForm) => {
  return request({
    url: '/market/book',
    method: 'put',
    data: data
  });
};

/**
 * 删除预约列表
 * @param id
 */
export const delBook = (id: string | number | Array<string | number>) => {
  return request({
    url: '/market/book/' + id,
    method: 'delete'
  });
};
